package com.jv.spring.init_destroy_bean;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@Component
public class TestIDBean implements InitializingBean, DisposableBean {

	@Value("${testBeanName}")
	private String testBeanName;

	private String testBeanNo;
	public void setTestBeanNo(String testBeanNo){
		this.testBeanNo = testBeanNo;
	}

	@Autowired
	private User user;

	@Resource
	private BeanProperty beanProperty;


	@Override
	public void destroy() throws Exception {
		System.out.println("TestIDBean destroy");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("TestIDBean afterPropertiesSet");
	}

	@PostConstruct
	public void postConstruct(){
		System.out.println("TestIDBean postConstruct");
	}

/*	@PostConstruct
	public void postConstruct(String p){
		System.out.println("TestIDBean postConstruct with parameter p");
	}*/

	@PostConstruct
	public void postConstruct1(){
		System.out.println("TestIDBean postConstruct1");
	}

	@PreDestroy
	public void preConstruct(){
		System.out.println("TestIDBean preConstruct");
	}

	@PreDestroy
	public void preConstruct1(){
		System.out.println("TestIDBean preConstruct1");
	}
}
